{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "19679994",
   "metadata": {},
   "source": [
    "---\n",
    "* 时间:2002/10/24 week10 \n",
    "* 记录人：马梓杰\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d0fe1054",
   "metadata": {},
   "source": [
    "# 本周学习目标\n",
    ">1. while 循环\n",
    ">2. 购物车实践"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b71dcde4",
   "metadata": {},
   "source": [
    "## 1. while循环\n",
    "* 回顾：for循环  ：for+range（）可以指定循环的次数---》关于网页URL队列的抓取实践\n",
    "* while循环：当某种条件成立时，停止循环\n",
    "* while True ：无限循环/死循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "4d8d33a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "芜湖 0\n",
      "芜湖 1\n",
      "芜湖 2\n",
      "芜湖 3\n",
      "芜湖 4\n",
      "芜湖 5\n",
      "芜湖 6\n",
      "芜湖 7\n",
      "芜湖 8\n",
      "芜湖 9\n",
      "芜湖 10\n",
      "芜湖 11\n",
      "芜湖 12\n",
      "芜湖 13\n",
      "芜湖 14\n",
      "芜湖 15\n",
      "芜湖 16\n",
      "芜湖 17\n",
      "芜湖 18\n",
      "芜湖 19\n",
      "芜湖 20\n",
      "芜湖 21\n",
      "芜湖 22\n",
      "芜湖 23\n",
      "芜湖 24\n",
      "芜湖 25\n",
      "芜湖 26\n",
      "芜湖 27\n",
      "芜湖 28\n",
      "芜湖 29\n",
      "芜湖 30\n",
      "芜湖 31\n",
      "芜湖 32\n",
      "芜湖 33\n",
      "芜湖 34\n",
      "芜湖 35\n",
      "芜湖 36\n",
      "芜湖 37\n",
      "芜湖 38\n",
      "芜湖 39\n",
      "芜湖 40\n",
      "芜湖 41\n",
      "芜湖 42\n",
      "芜湖 43\n",
      "芜湖 44\n",
      "芜湖 45\n",
      "芜湖 46\n",
      "芜湖 47\n",
      "芜湖 48\n",
      "芜湖 49\n",
      "芜湖 50\n",
      "芜湖 51\n",
      "芜湖 52\n",
      "芜湖 53\n",
      "芜湖 54\n",
      "芜湖 55\n",
      "芜湖 56\n",
      "芜湖 57\n",
      "芜湖 58\n",
      "芜湖 59\n",
      "芜湖 60\n",
      "芜湖 61\n",
      "芜湖 62\n",
      "芜湖 63\n",
      "芜湖 64\n",
      "芜湖 65\n",
      "芜湖 66\n",
      "芜湖 67\n",
      "芜湖 68\n",
      "芜湖 69\n",
      "芜湖 70\n",
      "芜湖 71\n",
      "芜湖 72\n",
      "芜湖 73\n",
      "芜湖 74\n",
      "芜湖 75\n",
      "芜湖 76\n",
      "芜湖 77\n",
      "芜湖 78\n",
      "芜湖 79\n",
      "芜湖 80\n",
      "芜湖 81\n",
      "芜湖 82\n",
      "芜湖 83\n",
      "芜湖 84\n",
      "芜湖 85\n",
      "芜湖 86\n",
      "芜湖 87\n",
      "芜湖 88\n",
      "芜湖 89\n",
      "芜湖 90\n",
      "芜湖 91\n",
      "芜湖 92\n",
      "芜湖 93\n",
      "芜湖 94\n",
      "芜湖 95\n",
      "芜湖 96\n",
      "芜湖 97\n",
      "芜湖 98\n",
      "芜湖 99\n"
     ]
    }
   ],
   "source": [
    "# 1. 指定次数\n",
    "count = 0\n",
    "while True:\n",
    "    print(\"芜湖\",count)\n",
    "    count += 1\n",
    "    if count == 100:\n",
    "        break # break 终止循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "5938d0fc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账号：11\n",
      "密码：11\n",
      "账号不存在或密码不正确！请重新输入！您还有1次尝试的机会\n",
      "账号：11\n",
      "密码：11\n",
      "账号不存在或密码不正确！请1小时候再来尝试\n"
     ]
    }
   ],
   "source": [
    "#2 . while True循环，可以让用户重复输入\n",
    "user01 = \"admin\"\n",
    "password01 = \"123456\"\n",
    "count = 0 # 计数器\n",
    "while True:\n",
    "    username = input(\"账号：\")\n",
    "    password = input(\"密码：\")\n",
    "    # 情景一：账号密码都正确\n",
    "    if user01 == username and  password01 == password:\n",
    "        print(\"登陆成功~欢迎\"+user01)\n",
    "        break # 中止循环\n",
    "    # 情景二：账号不存在或密码不正确，用户可以输入三次，三次之后1小时之后再来尝试\n",
    "    else:\n",
    "        count += 1\n",
    "        if count<3:\n",
    "            print(\"账号不存在或密码不正确！请重新输入！您还有\"+str(3-count)+\"次尝试的机会\")\n",
    "        else:\n",
    "            print(\"账号不存在或密码不正确！请1小时候再来尝试\")\n",
    "            break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a59609dc",
   "metadata": {},
   "source": [
    "## 2. 购物车项目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "0f92baf0",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (2424412081.py, line 22)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [29]\u001b[1;36m\u001b[0m\n\u001b[1;33m    user_choice = input(\"请输入商品编号：\")\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# 1. 运行程序后，让用户输入支付宝余额，然手打印我们的商品列表给用户\n",
    "\n",
    "\n",
    "product_list = [\n",
    "('皮蛋瘦肉粥三件套', 13),\n",
    "('雪菜笋丁鸡肉粥三件套', 10),\n",
    "('生滚牛肉粥三件套', 17),\n",
    "('皮蛋瘦肉粥油条三件套', 13),\n",
    "('培根蛋法风烧饼咖啡三件套', 20),\n",
    "(\"大饼卷香饼鸡扒蛋豆浆三件套\", 22),\n",
    "(\"芝士猪柳蛋帕尼尼豆浆三件套\", 22),\n",
    "(\"肯德基活力全餐周末\", 26),\n",
    "(\"芝士猪柳帕尼尼全餐\", 28),\n",
    "(\"西瓜冰红茶\", 1000)\n",
    "]\n",
    "Alipay = input(\"请输入余额：\")\n",
    "print(\"------商品列表--------\")\n",
    "for i in range(4):\n",
    "    print(\"商品序号\",(\"+str(i)+\"),product_list[i][0], str(product_list[i][1] + \"元\")\n",
    "\n",
    "          \n",
    "user_choice = input(\"请输入商品编号：\")\n",
    "          \n",
    "# 情景一：余额大于商品价格"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4eba9ca",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1fce5d1b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd1cf157",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0ef1c69a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4ebbb02f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6f8e93c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e9cbde2f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd8e2505",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbd74520",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3b373acc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ddd515e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b5e694f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24d5853f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b090fad",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d4c123f4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d654d2ba",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9a473b35",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "50ccaf75",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2edd0ff1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6e1db6c9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "741cc1c5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
